package 寒假刷题;

public class 气球的最大数量 {
    // balloon
    public int maxNumberOfBalloons(String text) {
        //统计每个单词的数目
        int[] nums = new int[26];
        char[] chars = text.toCharArray();
        for (char c : chars) {
            int i = c - 'a';
            nums[i]++;
        }
        int min = nums[0];
        for (int i = 0; i < nums.length; i++) {
            if (i+'a'=='b' || i+'a'=='n')
                min = Math.min(min,nums[i]);
            if (i+'a'=='l' || i+'a'=='o')
                min = Math.min(min,nums[i]/2);
        }
        return min;
    }
}
